package com.zackratos.toprouter

import com.zackratos.component1.TComponent1
import com.zackratos.component2.TComponent2
import com.zackratos.component3.TComponent3
import com.zackratos.component4.TComponent4


/**
 * @Author   : zhangwenchao
 * @Date     : 2020/12/29  8:08 PM
 * @Describe :
 */
class TopRouterManager private constructor() {

    companion object {
        fun getInstance(): TopRouterManager = Holder.INSTANCE
    }

    private object Holder {
        val INSTANCE = TopRouterManager()
    }

    private val component1: TopComponent1 by lazy { TopComponent1() }

    private val component2: TopComponent2 by lazy { TopComponent2() }

    private val component3: TopComponent3 by lazy { TopComponent3() }

    private val component4: TopComponent4 by lazy { TopComponent4() }


    fun initialization() {
        TComponent1.getInstance().observable = component1
        TComponent2.getInstance().observable = component2
        TComponent3.getInstance().observable = component3
        TComponent4.getInstance().observable = component4

        component1.subscribe(component2)
        component1.subscribe(component3)
        component1.subscribe(component4)

        component2.subscribe(component1)
        component2.subscribe(component3)
        component2.subscribe(component4)

        component3.subscribe(component1)
        component3.subscribe(component2)
        component3.subscribe(component4)

        component4.subscribe(component1)
        component4.subscribe(component2)
        component4.subscribe(component3)
    }



}